package com.zy.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.mapper.DelMapper;
import com.zy.pojo.Recycle;
import com.zy.service.DelService;
import com.zy.vo.Del.DelVo;
import com.zy.vo.ManagementVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;
@Service("delService")
public class DelServiceImpl extends ServiceImpl<DelMapper, Recycle> implements DelService {
    @Resource
    private DelMapper delMapper;
    @Override
    public List<Recycle> getDelList() {
        return delMapper.selectList(null);
    }

    @Override
    public void getDelPurList(Recycle recycle) {
        delMapper.getdelPer(recycle);
    }

    @Override
    public void del(Integer id) {
delMapper.deleteById(id);
    }

    @Override
    public DelVo getPage(Integer pageNo, Integer pageSize, ManagementVo managementVo) {
        Page page =new Page();
        page.setSize(pageSize);
        page.setCurrent(pageNo);
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.like(!StringUtils.isEmpty(managementVo.getUserCode()),"del_lingcode",managementVo.getUserCode());

        List<Recycle> list =delMapper.getDelList(page,queryWrapper);
        return new DelVo(list,page.getTotal());
    }
}
